*******************************************************************************
* Purpose: Analyses on fertility and divorce outcomes
*******************************************************************************

do "D:\Data\workdata\708296\Project - Mother groups and mental health\Do\global.do" 

use "$work\final_data1", clear
********************************************************************************
* Table C12: Effects of exposure to a peer with mental health issues on fertility and cohabitation
********************************************************************************
foreach var in fert2 cohab2 fert3 cohab3 fert5 cohab5{
eststo: areg `var' peer_treat, absorb(time fe mfr_first) vce(cluster group) 
estimates store g`var'
summarize `var' if peer_treat == 0 , meanonly
estadd scalar means = r(mean)
}
esttab g* using "$out\fertcohab_5y.tex", fragment b(3) se(3) keep(peer_treat) stats(means N, fmt(%13.2fc %13.0fc) label("Control group mean" "Obs.")) se star(* 0.10 ** 0.05 *** 0.01) alignment(c c) label nolegend nonote replace



/** asked for by referees - not in paper version**

use "$work\final_data1", clear
gen epds = 0
replace epds = 1 if score_e1 > 4 & score_e1 < 11

eststo clear
forvalues j = 0/1 {
foreach v of varlist fert2 cohab2 fert3 cohab3 fert5 cohab5 {
areg `v' peer_treat if epds == `j', absorb(time fe mfr_first) vce(cluster group)
estimates store f`j'`v'
summarize `v' if peer_treat == 0 & epds == `j', meanonly
estadd scalar means = r(mean)
}
}
esttab f0* using "$out\fertcohab_epds.tex", fragment b(3) se(3) keep(peer_treat) stats(means N, fmt(%13.2fc %13.0fc) label("Control group mean" "Obs.")) se star(* 0.10 ** 0.05 *** 0.01) alignment(c c) label nolegend nonote replace

esttab f1* using "$out\fertcohab_epds.tex", fragment b(3) se(3) keep(peer_treat) stats(means N, fmt(%13.2fc %13.0fc) label("Control group mean" "Obs.")) se star(* 0.10 ** 0.05 *** 0.01) alignment(c c) label nolegend nonote append

forvalues i = 1/103 {
	replace barsel104 = barsel104 + barsel`i'
	replace sick104 = sick104 + sick`i'
	replace work104 = work104 + work`i'
	replace ui104 = ui104 + ui`i'
	
}
eststo clear
forvalues j = 0/1 {
foreach v of varlist barsel104 sick104 work104 ui104 {
areg `v' peer_treat if epds == `j', absorb(time fe mfr_first) vce(cluster group)
estimates store g`j'`v'
summarize `v' if peer_treat == 0 & epds == `j', meanonly
estadd scalar means = r(mean)
}
}
esttab g0* using "$out\labor_epds.tex", fragment b(3) se(3) keep(peer_treat) stats(means N, fmt(%13.2fc %13.0fc) label("Control group mean" "Obs.")) se star(* 0.10 ** 0.05 *** 0.01) alignment(c c) label nolegend nonote replace

esttab g1* using "$out\labor_epds.tex", fragment b(3) se(3) keep(peer_treat) stats(means N, fmt(%13.2fc %13.0fc) label("Control group mean" "Obs.")) se star(* 0.10 ** 0.05 *** 0.01) alignment(c c) label nolegend nonote append